<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
 <title>Inspire - Admin and Dashboard Template</title>
 <link rel="stylesheet" type="text/css" href="/assets/css/bootstrap.min.css">
 <link rel="stylesheet" type="text/css" href="/assets/fonts/line-icons.css">
 <link rel="stylesheet" type="text/css" href="/assets/css/main.css">
 <link rel="stylesheet" type="text/css" href="/assets/css/responsive.css">
</head>
<body>
<div class="card-header border-bottom">
 <h4 class="card-title" >查询排片信息</h4>
</div>
<div th:class="msg" th:text="${ msg }" ></div>
<div class="col-12 grid-margin">
 <div class="card">
  <div class="card-body">
   <form class="form-sample" id="films">
    <div class="row">
     <div class="col-md-6">
      <div class="form-group row">
       <label class="col-sm-3 col-form-label">影厅</label>
       <div class="col-sm-9">
        <select name="cinemaId" id="cinemaId" class="form-control">
         <option th:each="t,line : ${cinemaList}" th:value="${t.id}" th:text="${ t.hall }" th:selected="${filmsUnique.cinemaId==t.id}"></option>
        </select>
       </div>
      </div>
     </div>
    </div>
    <div class="row">
     <div class="col-md-6">
      <div class="form-group row">
       <label class="col-sm-3 col-form-label">选择电影</label>
       <div class="col-sm-9">
        <select class="form-control" id="movieId" name="movieId">
         <option th:each="t,line : ${ movieList }" th:value="${ t.id }" th:text="${ t.movieName }" th:selected="${filmsUnique.movieId==t.id}" ></option>
        </select>
       </div>
      </div>
     </div>
    </div>

    <div class="row">
     <div class="col-md-6">
      <div class="form-group row">
       <label class="col-sm-3 col-form-label">播放开始时间</label>
       <div class="col-sm-9">
        <input type="datetime-local" class="form-control" id="startTime"
               name="startTime" th:value="${#dates.format(filmsUnique.startTime,'yyyy-MM-dd')+'T'+#dates.format(filmsUnique.startTime,'HH:mm')}">
       </div>
      </div>
     </div>
    </div>
   <div class="row">
       <div class="col-md-6">
           <div class="form-group row">
               <label class="col-sm-3 col-form-label">间隔时间</label>
               <div class="col-sm-9">
                   <select class="form-control" id="spare" name="spare">
                       <option th:selected="${filmsUnique.spare==10}" th:value="10">10分钟</option>
                       <option th:selected="${filmsUnique.spare==20}" th:value="20">20分钟</option>
                       <option th:selected="${filmsUnique.spare==30}" th:value="30">30分钟</option>
                   </select>
               </div>
           </div>
       </div>
   </div>
    <div class="row">
     <div class="col-md-6">
      <div class="form-group row">
       <label class="col-sm-3 col-form-label">票价</label>
       <div class="col-sm-9">
        <input type="text" class="form-control" name="price" id="price" th:value="${filmsUnique.price}">
       </div>
      </div>
     </div>
    </div>

    <input type="button" class="btn btn-common mr-3" id="update" value="修改"></input>
    <input type="button" class="btn btn-common mr-3" id="delete" value="删除"></input>
    <input type="button" class="btn btn-light" id="quxiao" value="返回"></input>
   </form>
  </div>
 </div>
</div>

<script th:inline="javascript">
  $(".msg").slideUp(3000);

  $("#price").bind("blur", price)
  function price() {
   var price = $("#price").val()
   if(!(/^[0-9]+([.]{1}[0-9]+){0,1}$/).test(price)){
    return false
   }else {
    return true
   }
  }


  $("#update").bind("click",function () {
   var cinemaId = $("#cinemaId").val();
   var movieId = $("#movieId").val();
   var startTime = $("#startTime").val();
   if(cinemaId=='' || movieId=='' || startTime==''){
    alert("不能为空")
    return
   }
   if(price()){
    if(!confirm("确定修改吗?")) return
    var id = [[${filmsUnique.id}]];
    toJump("/films/modify",$("#films").serialize()+"&id="+id)
   }else{
    alert("格式错误！")
   }

  })
 $("#delete").bind("click",function () {
   if(!confirm("确定删除吗?")) return
   var id = [[${filmsUnique.id}]];
  toJump("/films/delete","&id="+id)
  })

 $("#quxiao").bind("click",function () {
  toJump("/films/updateQuery")
 })
</script>


<script src="/assets/js/jquery-min.js"></script>
<script src="/assets/js/popper.min.js"></script>
<script src="/assets/js/bootstrap.min.js"></script>
<script src="/assets/js/jquery.app.js"></script>
<script src="/assets/js/main.js"></script>
<script src="/assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.bootstrap4.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.buttons.min.js"></script>
<script src="/assets/plugins/datatables/buttons.bootstrap4.min.js"></script>
<script src="/assets/plugins/datatables/jszip.min.js"></script>
<script src="/assets/plugins/datatables/pdfmake.min.js"></script>
<script src="/assets/plugins/datatables/vfs_fonts.js"></script>
<script src="/assets/plugins/datatables/buttons.html5.min.js"></script>
<script src="/assets/plugins/datatables/buttons.print.min.js"></script>
<script src="/assets/plugins/datatables/buttons.colVis.min.js"></script>
<script src="/assets/plugins/datatables/dataTables.responsive.min.js"></script>
<script src="/assets/plugins/datatables/responsive.bootstrap4.min.js"></script>
</body>
</html>